package test.gwalo;

import lew.bing.gwalo.BingoConfiguration;
import lew.bing.gwalo.semaphoreLimiter.DefaultPermits;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

/**
 * Created by 刘国兵 on 2018/7/7.
 */
@SpringBootApplication(scanBasePackages = {"lew.bing","test.gwalo"})
@EnableAspectJAutoProxy
public class Bootstrap {

    public static void main(String[] args) throws InterruptedException {
        ConfigurableApplicationContext context = SpringApplication.run(Bootstrap.class, args);
        Test1 bean = context.getBean(Test1.class);
        BingoConfiguration.permitsMap.put("sl:123",1);
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    bean.sleep1s();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                     bean.sleep1s();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();
        Thread.sleep(3000);
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    bean.sleep1s();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();
        thread.join();
    }



}
